<template>
    <square-button icon="el-icon-star-on" :title="title" v-on="$listeners" v-bind="$attrs" @click="toCollect"
                   :class="{'collect':isCollect}"></square-button>
</template>
<script>
    import SquareButton from "@/components/WorkFlowsDialog/Case/SquareButton";
    //import schoolSignature from "@/api/officialDocument/schoolSignature/index";

    export default {
        name: "FollowButton",
        components: {SquareButton},
        props: {
            row: {
                type: Object,
                default: function () {
                    return {}
                }
            }
        },
        data() {
            return {
                isCollect: 0
            }
        },
        computed: {
            title(){
                return this.isCollect?"取消关注":"关注"
            }
        },
        created() {
            this.isCollect = this.row.is_collect
        },
        methods: {
            collect() {
                // schoolSignature.collect(this.row.id).then(res => {
                //     this.msgSuccess(res.msg)
                //     this.isCollect = 1
                // })
            },
            uncollect() {
                // schoolSignature.uncollect(this.row.id).then(res => {
                //     this.msgSuccess(res.msg)
                //     this.isCollect = 0
                // })
            },
            toCollect() {
                if (this.isCollect) {
                    this.uncollect()
                } else {
                    this.collect()
                }
            }
        }
    }
</script>
<style lang="scss" scoped>
    .collect {
        background-color: #1890ff;
        color: #fff;
    }
</style>
